#include <iostream>
#include <string>

using namespace std;

class Base
{
public:
    Base(string name, int age)
    {
        cout << "Base construction" << endl;
        m_name = name;
        m_age = age;
    }
    string getName()
    {
        return this->m_name;
    }

    int getAge()
    {
        return this->m_age;
    }

private:
    string m_name;
    int m_age;
};

class Son : public Base
{
public:
    Son(string name, int age);
};

Son::Son(string name, int age) : Base(name, age)
{
    cout << "Son construction" << endl;
}

class Test
{
friend void test();
public:
    Test(char cc);
private:
    Base m_base;
    const int a;
    char &c;
};
// 必须使用参数化列表的方法进行初始化，因为Base没有提供默认构造函数
// 参数化列表要放在实现{}前面
Test::Test(char cc) : m_base("laowang", 88) , a(5) , c(cc)
{
    cout << "Test construct " << endl;
}

void test()
{
    // Son son1("WWW", 22);
    // cout << "name :" << son1.getName() << endl;
    Test test('u');
    cout << test.m_base.getName() << endl;
    cout << test.m_base.getAge() << endl;
}

int main()
{
    test();
    return 0;
}